This patch implements select() functionality on /dev/vtpm and fixes some
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 12 Oct 2005 08:33:03 +0000 (09:33 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 12 Oct 2005 08:33:03 +0000 (09:33 +0100)
other problems.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c

index f5c0ccb10a5844542e35f22826173182cadda449..0a8d70528c12978703b68615410eb6f97161603c 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/types.h>
 #include <linux/list.h>
 #include <linux/miscdevice.h>
+#include <linux/poll.h>
 #include <asm/uaccess.h>
 #include <asm-xen/xenbus.h>
 #include <asm-xen/xen-public/grant_table.h>
@@ -680,9 +681,14 @@ vtpm_op_release(struct inode *inode, struct file *file)
 }
 
 static unsigned int
-vtpm_op_poll(struct file *file, struct poll_table_struct *pst)
+vtpm_op_poll(struct file *file, struct poll_table_struct *pts)
 {
-       return 0;
+       unsigned int flags = POLLOUT | POLLWRNORM;
+       poll_wait(file, &dataex.wait_queue, pts);
+       if (!list_empty(&dataex.pending_pak)) {
+               flags |= POLLIN | POLLRDNORM;
+       }
+       return flags;
 }
 
 static struct file_operations vtpm_ops = {
index 09ffb0200264c2cea46802fc718b8b9858cfa7ab..9276c19354ae6e70c7619a0de25e5374addb0083 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/tpmfe.h>
+#include <linux/err.h>
 
 #include <asm/semaphore.h>
 #include <asm/io.h>
@@ -372,7 +373,7 @@ again:
        info->watch.callback = watch_for_status;
        err = register_xenbus_watch(&info->watch);
        if (err) {
-               message = "registering watch on backend";
+               xenbus_dev_error(dev, err, "registering watch on backend");
                goto destroy_tpmring;
        }
 
@@ -398,6 +399,8 @@ static int tpmfront_probe(struct xenbus_device *dev,
        int err;
        struct tpmfront_info *info;
        int handle;
+       int len = max(XS_WATCH_PATH, XS_WATCH_TOKEN) + 1;
+       const char *vec[len];
 
        err = xenbus_scanf(NULL, dev->nodename,
                           "handle", "%i", &handle);
@@ -427,6 +430,10 @@ static int tpmfront_probe(struct xenbus_device *dev,
                return err;
        }
 
+       vec[XS_WATCH_PATH]  = info->watch.node;
+       vec[XS_WATCH_TOKEN] = NULL;
+       watch_for_status(&info->watch, vec, len);
+
        return 0;
 }